package org.jeecg.modules.util;

import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.projectmanagement.entity.TimeCardVO;

import java.sql.SQLOutput;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TimeCardUtils {
    static long day_ms = 1000 * 60*60*24;

    /**
     *
     * @param vo
     * @return
     */
    public static String  getCardName(TimeCardVO vo){
        Date validDate = vo.getValidDate();
        Date now =new Date();
        long time = validDate.getTime();
        long time2 = now.getTime();
        String ex = "";
        if (time < time2){
            ex="【已过期】";
        }else{
            int days =(int) ((time - time2)/day_ms);
           /* if (days < 30){
                ex="【剩余"+days+"天】";
            }*/
            ex="【剩余"+getDateDiscrepency(time - time2)+"】";
        }

        return vo.getName()+ex;
    }

    public static String  getCardName(String name,Date validDate){
        System.out.println("lukasLi debug:"+name+validDate.toString());
        Date now =new Date();
        long time = validDate.getTime();
        long time2 = now.getTime();
        String ex = "";
        if (time < time2){
            ex="【已过期】";
        }else{
            int days =(int) ((time - time2)/day_ms);
           /* if (days < 30){*/
                ex="【剩余"+getDateDiscrepency(time - time2)+"】";
           /* }*/
        }

        return name+ex;
    }


    public static String getDateDiscrepency(long diff) {

        long nd = 1000 * 24 * 60 * 60;
        long nh = 1000 * 60 * 60;
        long nm = 1000 * 60;
        // long ns = 1000;
        // 获得两个时间的毫秒时间差异
        // 计算差多少天
        long day = diff / nd;
        // 计算差多少小时
        long hour = diff % nd / nh;
        // 计算差多少分钟
        long min = diff % nd % nh / nm;
        // 计算差多少秒//输出结果
        // long sec = diff % nd % nh % nm / ns;
        return day + "天" + hour + "小时" /*+ min + "分钟"*/;
    }

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
            list.add("memberId");

            list.add("payType");
        System.out.println(list.toString()+"no");
    }
}
